set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

message(STATUS "top_dir: ${TOP_DIR}")
if(OHOS_LITE)
    set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++11 -Wall -Wl,--disable-new-dtags")
else()
    set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++17 -Wall -Wl,--disable-new-dtags")
endif()
set(ffmpeg_lib_path ${THIRD_PARTY_DIR}/ffmpeg/linux/lib)
set(ffmpeg_inc_path ${THIRD_PARTY_DIR}/ffmpeg/linux/include)
set(sdl_lib_path ${THIRD_PARTY_DIR}/SDL2.0/linux/lib)
set(sdl_inc_path ${THIRD_PARTY_DIR}/SDL2.0/include)
set(curl_lib_path ${THIRD_PARTY_DIR}/curl/lib/linux)

file(GLOB sdl_shared_libraries ${sdl_lib_path}/*.so.*)
file(COPY ${ffmpeg_shared_libraries} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
file(COPY ${sdl_shared_libraries} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

set(CMAKE_VERBOSE_MAKEFILE ON)

include_directories(
        ${TOP_DIR}/histreamer/engine/include
        ${TOP_DIR}/histreamer/engine/factory
)

if(OHOS_LITE)
        include_directories(
                ${TOP_DIR}/histreamer/engine/scene/lite
        )
endif()

set(PLAYER_SRCS
        ${TOP_DIR}/demo/linux/player.cpp
)

set(RECORDER_SRCS
        ${TOP_DIR}/demo/linux/recorder.cpp
)

message(STATUS "${ffmpeg_lib_path}")
link_directories(
        ${ffmpeg_lib_path}
        ${sdl_lib_path}
        ${curl_lib_path}
        ${histreamer_SRC_DIR}
)

if (${OHOS_LITE})
    add_definitions(-DOHOS_LITE)
endif ()

link_libraries(
        histreamer
        pthread
        dl
        ${ffmpeg_lib_path}/libavformat.a
        ${ffmpeg_lib_path}/libavcodec.a
        ${ffmpeg_lib_path}/libavdevice.a
        ${ffmpeg_lib_path}/libavfilter.a
        ${ffmpeg_lib_path}/libavutil.a
        ${ffmpeg_lib_path}/libswscale.a
        ${ffmpeg_lib_path}/libswresample.a
        ${ffmpeg_lib_path}/liblzma.a
        ${sdl_lib_path}/libSDL2.a
        m
        /usr/lib/x86_64-linux-gnu/libz.so.1
        ${curl_lib_path}/libcurl.so
)

add_executable(histreamer_player ${PLAYER_SRCS} ${3RDPARTY_SRCS})
if(NOT OHOS_LITE)
    add_executable(histreamer_recorder ${RECORDER_SRCS} ${3RDPARTY_SRCS})
endif()
